package com.jinlejia.feedback.idea.ui;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jinlejia.feedback.R;

/**
 * @author SongJiaTai
 * @description:加载弹框
 * @date :2019/6/28 17:21
 */
public class FbProgressDialog extends AlertDialog{
    private String tip;
    private Context mContext;

    public  FbProgressDialog(Context context) {
        super(context);
    }

    public FbProgressDialog(Context context, String tips) {
        super(context);
        this.mContext = context;
        this.tip = tips;
    }

    private boolean canCancel = true;
    public FbProgressDialog(Context context, String tips,boolean canCancel){
        super(context);
        this.mContext = context;
        this.tip = tips;
        this.canCancel = canCancel;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setCanceledOnTouchOutside(false);
        Window window = this.getWindow();
        // *** 主要就是在这里实现这种效果的.
        // 设置窗口的内容页面,shrew_exit_dialog.xml文件中定义view内容
        window.setContentView(R.layout.fb_dialog_progress);
        window.setGravity(Gravity.CENTER);
        window.setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        window.setBackgroundDrawable(new ColorDrawable());
        setCanceledOnTouchOutside(canCancel);
//        AVLoadingIndicatorView circleProgressBar = (AVLoadingIndicatorView) findViewById(R.id.id_progress);
        TextView tips = (TextView) findViewById(R.id.id_progress_tips);
        tips.setText(tip);

    }
}
